<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:p="http://primefaces.org/ui"
                template="/templates/ui.xhtml">

    <ui:define name="head">
        <link type="text/css" href="#{request.contextPath}/UI/epss/epss.css" rel="stylesheet"/>
        <script type="text/javascript" src="#{request.contextPath}/UI/support/pub.js"/>
        <script type="text/javascript" language="javascript">
            document.onkeydown = function TabReplace() {
                if (event.keyCode == 13) {
                    if (event.srcElement.tagName != 'BUTTON')
                        event.keyCode = 9;
                    else
                        event.srcElement.click();
                }
            }
            function actSelect(obj, pageName) {
                var pkid = obj;
                var sfeature = "dialogwidth:1100px;dialogheight:600px;center:yes;location:no;help:no;resizable:no;scroll:yes;status:no";
                var arg = new Object();
                arg.doType = "select";
                if (pageName == "Cstpl_Detail") {
                    var rtn = dialog("../item/itemMng_Tk_Cstpl.xhtml?strType=1&amp;strCstplPkid=" + pkid + "", arg, sfeature);
                } else if (pageName == "Attachment") {
                    var rtn = window.open("/epss/servlet/ShowServlet?operType=Mng&amp;strType=0&amp;strPkid=" + pkid + "",
                            'popupwindow',
                            'height = 300,width = 450,location = no,resizable = no,scrollbars = no,status = no,toolbar = no,top = 100');
                }
            }
        </script>
    </ui:define>
    <ui:define name="content">
        <h:form id="form" enctype="multipart/form-data">
            <p:growl id="msgs" showDetail="true"/>
            <p:focus for="id"/>
            <p:panel>
                <h:panelGrid id="pdQry" columns="2" style="width: 100%">
                    <h:panelGrid columns="4">
                        <p:outputLabel value="计划编号：" for="id"/>
                        <p:inputText id="id" value="#{cstplInfoAction.cttInfoShowQry.id}"
                                     style="width: 200px"/>
                        <p:outputLabel value="计划名称：" for="cstplName"/>
                        <p:inputText id="cstplName" value="#{cstplInfoAction.cttInfoShowQry.name}"
                                     style="width: 360px"/>
                    </h:panelGrid>
                    <h:panelGrid columns="3">
                        <p:commandButton id="qryBtn" value="查询"
                                         action="#{cstplInfoAction.onQueryAction('Mng','true')}"
                                         update="pdt,msgs,pgCondition">
                        </p:commandButton>
                        <p:commandButton id="resetBtn" value="重置"
                                         type="reset"
                                         update="pdQry,msgs">
                        </p:commandButton>
                        <p:ajaxStatus style="width:16px;height:16px;">
                            <f:facet name="start">
                                <h:graphicImage value="/images/ajaxloading.gif"/>
                            </f:facet>
                            <f:facet name="complete">
                                <h:outputText value=""/>
                            </f:facet>
                        </p:ajaxStatus>
                    </h:panelGrid>
                </h:panelGrid>
            </p:panel>
            <h:panelGrid id="pgCondition" columns="4">
                <p:commandButton id="addBtn"
                                 value="增加" icon="ui-icon-plus"
                                 action="#{cstplInfoAction.resetActionForAdd()}"
                                 update="pgCondition,pgViewForAdd"
                                 onclick="PF('wVDlgViewForAdd').show()">
                </p:commandButton>
                <p:commandButton id="endInputBtn" value="录入完成"
                                 action="#{cstplInfoAction.onClickForPowerAction('MngPass')}"
                                 update="pgCondition,pdt,msgs"
                                 rendered="#{cstplInfoAction.rowSelectedFlag}">
                </p:commandButton>
                <p:commandButton id="startInputBtn" value="录入未完"
                                 action="#{cstplInfoAction.onClickForPowerAction('MngFail')}"
                                 update="pgCondition,pdt,msgs"
                                 rendered="#{cstplInfoAction.rowSelectedFlag}">
                </p:commandButton>
            </h:panelGrid>
            <p:contextMenu for="pdt">
                <p:menuitem value="选择" icon="ui-icon-plus"
                            actionListener="#{cstplInfoAction.selectRecordAction('Mng','Sel')}"
                            update="pdt,msgs,pgCondition">
                </p:menuitem>
                <p:menuitem value="更新" icon="ui-icon-arrowrefresh-1-w"
                            actionListener="#{cstplInfoAction.selectRecordAction('Mng','Upd')}"
                            update="pdt,msgs,pgViewForUpd,pgCondition"
                            onclick="PF('wVDlgViewForUpd').show()">
                </p:menuitem>
                <p:menuitem value="删除" icon="ui-icon-close"
                            actionListener="#{cstplInfoAction.selectRecordAction('Mng','Del')}"
                            update="pdt,msgs,pgViewForDel,pgCondition"
                            onclick="PF('wVDlgViewForDel').show()">
                </p:menuitem>
                <p:menuitem value="详细内容" icon="ui-icon-search"
                            oncomplete="actSelect(DtInitCstplList.selection,'Cstpl_Detail')">
                </p:menuitem>
                <p:menuitem value="附件" icon="ui-icon-search"
                            oncomplete="actSelect(DtInitCstplList.selection,'Attachment')">
                </p:menuitem>
            </p:contextMenu>
            <p:dataTable id="pdt" style="width:100%;"
                         value="#{cstplInfoAction.cttInfoShowList}"
                         var="record"
                         rowKey="#{record.pkid}"
                         selection="#{cstplInfoAction.cttInfoShowSelected}"
                         selectionMode="single"
                         paginatorTemplate="{FirstPageLink} {PreviousPageLink} {PageLinks}
                         {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
                         paginator="true"
                         paginatorPosition="bottom"
                         rows="15"
                         rowsPerPageTemplate="500,200,100,45,30,15"
                         emptyMessage="数据记录为空..."
                         widgetVar="DtInitCstplList"
                         rowStyleClass="#{record.statusFlag eq null? null:'rowDoneStyle'}"
                         scrollable="true">
                <p:column headerText="成本计划号" style="width:140px;text-align:center">
                    <h:outputText value="#{record.id}"/>
                </p:column>
                <p:column headerText="成本计划名" style="text-align:left">
                    <h:outputText value="#{record.name}"/>
                </p:column>
                <p:column headerText="状态标志" style="width:60px;text-align:center">
                    <h:outputText value="#{esFlowControl.getLabelByValueInStatusFlaglist(record.statusFlag)}"/>
                </p:column>
                <p:column headerText="原因" style="width:60px;text-align:center">
                    <h:outputText value="#{esFlowControl.getLabelByValueInPreStatusFlaglist(record.preStatusFlag)}"/>
                </p:column>
                <p:column headerText="制定日期" style="width:66px;text-align:center">
                    <h:outputText value="#{record.signDate}"/>
                </p:column>
                <p:column headerText="备注内容" style="text-align:center">
                    <h:outputText value="#{record.note}"/>
                </p:column>
            </p:dataTable>
            <p:dialog id="dlgViewForAdd" header="成本计划增加信息" widgetVar="wVDlgViewForAdd"
                      resizable="false" modal="true"
                      showEffect="clip" hideEffect="fold">
                <h:panelGrid id="pgViewForAdd">
                    <h:panelGrid columns="3">
                        <p:outputLabel value="计划编号：" for="idForAdd"/>
                        <p:inputText id="idForAdd" value="#{cstplInfoAction.cttInfoShowAdd.id}"/>
                        <p:commandButton id="autoSetIdBtnForAdd" icon="ui-icon-plus"
                                         action="#{cstplInfoAction.setMaxNoPlusOne()}"
                                         update="idForAdd"
                                         style="height:20px">
                        </p:commandButton>
                    </h:panelGrid>
                    <h:panelGrid columns="2">
                        <p:outputLabel value="计划名称：" for="cstplNameForAdd"/>
                        <p:inputText id="cstplNameForAdd" value="#{cstplInfoAction.cttInfoShowAdd.name}"
                                     style="width:340px"/>
                    </h:panelGrid>
                    <h:panelGrid columns="4">
                        <p:outputLabel value="制定日期：" for="signDateForAdd"/>
                        <p:inputText id="signDateForAdd" value="#{cstplInfoAction.cttInfoShowAdd.signDate}"
                                     onclick="WdatePicker({dateFmt:'yyyy-MM-dd'})"/>
                        <p:outputLabel value="备注内容：" for="noteForAdd"/>
                        <p:inputText id="noteForAdd" value="#{cstplInfoAction.cttInfoShowAdd.note}"/>
                    </h:panelGrid>                     
                    <h:panelGrid id="pgOperBtnForAdd" columns="2">
                        <p:commandButton id="submitBtnForAdd"
                                         value="提交（增加）"
                                         action="#{cstplInfoAction.onClickForMngAction()}"
                                         update="pdt,msgs,pgViewForAdd">
                        </p:commandButton>
                        <p:commandButton id="resetBtnForAdd" value="重置"
                                         type="reset"
                                         update="pgViewForAdd">
                        </p:commandButton>
                    </h:panelGrid>
                </h:panelGrid>
            </p:dialog>
            <p:dialog id="dlgViewForUpd" header="成本计划更新信息" widgetVar="wVDlgViewForUpd"
                      resizable="false" modal="true"
                      showEffect="clip" hideEffect="fold">
                <h:panelGrid id="pgViewForUpd">
                    <h:panelGrid columns="3">
                        <p:outputLabel value="计划编号：" for="idForUpd"/>
                        <p:inputText id="idForUpd" value="#{cstplInfoAction.cttInfoShowUpd.id}"/>
                        <p:commandButton id="autoSetIdBtnForUpd" icon="ui-icon-plus"
                                         action="#{cstplInfoAction.setMaxNoPlusOne()}"
                                         update="idForUpd"
                                         style="height:20px">
                        </p:commandButton>
                    </h:panelGrid>
                    <h:panelGrid columns="2">
                        <p:outputLabel value="计划名称：" for="cstplNameForUpd"/>
                        <p:inputText id="cstplNameForUpd" value="#{cstplInfoAction.cttInfoShowUpd.name}"/>
                    </h:panelGrid>
                    <h:panelGrid columns="4">
                        <p:outputLabel value="制定日期：" for="signDateForUpd"/>
                        <p:inputText id="signDateForUpd" value="#{cstplInfoAction.cttInfoShowUpd.signDate}"
                                     onclick="WdatePicker({dateFmt:'yyyy-MM-dd'})"/>
                        <p:outputLabel value="备注内容：" for="noteForUpd"/>
                        <p:inputText id="noteForUpd" value="#{cstplInfoAction.cttInfoShowUpd.note}"/>
                    </h:panelGrid>
                    <h:panelGrid columns="4">
                        <p:outputLabel for="createdByNameForUpd" value="创建人：" />
                        <h:inputText id="createdByNameForUpd"
                                     value="#{cstplInfoAction.cttInfoShowUpd.createdByName}"
                                     style="background-color:gainsboro" readonly="true"/>
                        <p:outputLabel for="createdDateForUpd" value="创建时间：" />
                        <h:inputText id="createdDateForUpd"
                                     value="#{cstplInfoAction.cttInfoShowUpd.createdDate}"
                                     style="background-color:gainsboro" readonly="true"/>
                        <p:outputLabel for="lastUpdByNameForUpd" value="修改人：" />
                        <h:inputText id="lastUpdByNameForUpd"
                                     value="#{cstplInfoAction.cttInfoShowUpd.lastUpdByName}"
                                     style="background-color:gainsboro" readonly="true"/>
                        <p:outputLabel for="lastUpdDateForUpd" value="修改时间：" />
                        <h:inputText id="lastUpdDateForUpd"
                                     value="#{cstplInfoAction.cttInfoShowUpd.lastUpdDate}"
                                     style="background-color:gainsboro" readonly="true"/>
                        <p:outputLabel for="modificationNumForUpd" value="修改次数：" />
                        <h:inputText id="modificationNumForUpd"
                                     value="#{cstplInfoAction.cttInfoShowUpd.modificationNum}"
                                     style="background-color:gainsboro;text-align:right;" readonly="true">
                            <f:convertNumber type="number" pattern="#,###,###,###,##0"/>
                        </h:inputText>
                    </h:panelGrid>
                    <h:panelGrid id="pgOperBtnForUpd" columns="2">
                        <p:commandButton id="submitBtnForUpd"
                                         value="提交（更新）"
                                         action="#{cstplInfoAction.onClickForMngAction()}"
                                         update="pdt,msgs,pgViewForUpd">
                        </p:commandButton>
                        <p:commandButton id="resetBtnForUpd" value="重置"
                                         type="reset"
                                         update="pgViewForUpd">
                        </p:commandButton>
                    </h:panelGrid>
                </h:panelGrid>
            </p:dialog>
            <p:dialog id="dlgViewForDel" header="成本计划删除信息" widgetVar="wVDlgViewForDel"
                      resizable="false" modal="true"
                      showEffect="clip" hideEffect="fold">
                <h:panelGrid id="pgViewForDel">
                    <h:panelGrid columns="3">
                        <p:outputLabel value="计划编号：" for="idForDel"/>
                        <p:inputText id="idForDel" value="#{cstplInfoAction.cttInfoShowDel.id}"
                                     readonly="true"
                                     style="background-color:gainsboro;"/>
                    </h:panelGrid>
                    <h:panelGrid columns="2">
                        <p:outputLabel value="计划名称：" for="cstplNameForDel"/>
                        <p:inputText id="cstplNameForDel" value="#{cstplInfoAction.cttInfoShowDel.name}"
                                     readonly="true"
                                     style="background-color:gainsboro;width:340px"/>
                    </h:panelGrid>
                    <h:panelGrid columns="4">
                        <p:outputLabel value="制定日期：" for="signDateForDel"/>
                        <p:inputText id="signDateForDel" value="#{cstplInfoAction.cttInfoShowDel.signDate}"
                                     readonly="true"
                                     style="background-color:gainsboro;"/>
                        <p:outputLabel value="备注内容：" for="noteForDel"/>
                        <p:inputText id="noteForDel" value="#{cstplInfoAction.cttInfoShowDel.note}"
                                     readonly="true"
                                     style="background-color:gainsboro;"/>
                    </h:panelGrid>
                    <h:panelGrid columns="4">
                        <p:outputLabel for="createdByNameForDel" value="创建人：" />
                        <h:inputText id="createdByNameForDel"
                                     value="#{cstplInfoAction.cttInfoShowDel.createdByName}"
                                     style="background-color:gainsboro" readonly="true"/>
                        <p:outputLabel for="createdDateForDel" value="创建时间：" />
                        <h:inputText id="createdDateForDel"
                                     value="#{cstplInfoAction.cttInfoShowDel.createdDate}"
                                     style="background-color:gainsboro" readonly="true"/>
                        <p:outputLabel for="lastUpdByNameForDel" value="修改人：" />
                        <h:inputText id="lastUpdByNameForDel"
                                     value="#{cstplInfoAction.cttInfoShowDel.lastUpdByName}"
                                     style="background-color:gainsboro" readonly="true"/>
                        <p:outputLabel for="lastUpdDateForDel" value="修改时间：" />
                        <h:inputText id="lastUpdDateForDel"
                                     value="#{cstplInfoAction.cttInfoShowDel.lastUpdDate}"
                                     style="background-color:gainsboro" readonly="true"/>
                        <p:outputLabel for="modificationNumForDel" value="修改次数：" />
                        <h:inputText id="modificationNumForDel"
                                     value="#{cstplInfoAction.cttInfoShowDel.modificationNum}"
                                     style="background-color:gainsboro;text-align:right;" readonly="true">
                            <f:convertNumber type="number" pattern="#,###,###,###,##0"/>
                        </h:inputText>
                    </h:panelGrid>
                    <h:panelGrid id="pgOperBtnForDel" columns="2">
                        <p:commandButton id="submitBtn"
                                         value="提交（删除）"
                                         action="#{cstplInfoAction.onClickForMngAction()}"
                                         update="pdt,msgs,pgViewForDel">
                        </p:commandButton>
                    </h:panelGrid>
                </h:panelGrid>
            </p:dialog>
        </h:form>
    </ui:define>
</ui:composition>